<div class="accordion-group">
    <div class="accordion-heading">
        <a class="accordion-toggle" data-toggle="collapse" href="#<%= id %>" style="padding: 0px 0px 0px 0px;">
            <!--data-parent="#accordion2"-->
            <label class="control-label-small" >属性</label>
            <p class="controls-text-small">1</p>
        </a>
    </div>
    <div id="<%= id %>" class="accordion-body collapse" >
        <div class="accordion-inner icd-element-attribute" style="padding: 0px 0px 0px 0px;">
            <div class="control-group form-horizontal" style="overflow:visible;margin: 0 0 0 0;">
                <label class="control-label-small" >名称</label>
                <p class="controls-text-small">1</p>
                <div class="controls-small icd-element-input" style="display:none;">
                    <input type="text" class="span3 icd-element-search"  value="1"  style="background-color: #f7f7f7"  data-provide="typeahead" data-items="10" autocomplete="off">
                </div>
            </div>
            <div class="control-group form-horizontal" style="margin: 0 0 0 0;">
                <label class="control-label-small" >类型</label>
                <p class="controls-text-small">Char</p>
                <div class="controls-small icd-element-input" style="display:none;">
                    <input type="text" class="span3 icd-element-search" value="Char" style="background-color: #f7f7f7"  data-provide="typeahead" data-items="10" autocomplete="off">
                </div>
            </div>
            <div class="control-group form-horizontal" style="margin: 0 0 0 0;">
                <label class="control-label-small" >多重性</label>
                <p class="controls-text-small">1...*</p>
                <div class="controls-small icd-element-input" style="display:none;">
                    <input type="text" class="span3 icd-element-search" value="Multi" style="background-color: #f7f7f7"  data-provide="typeahead" data-items="10" autocomplete="off">
                </div>
            </div>
            <div class="btn-group controls-text-small" style="display:none;">
                <a href="javascript:;" class="btn btn-primary icd-element-attribute-input-submit">确定</a>
                <a href="javascript:;" class="btn icd-element-attribute-input-cancel">取消</a>
                <a href="javascript:;" class="btn icd-element-attribute-input-delete">删除</a>
            </div>
        </div>
    </div>
</div>

<script>
    $(function(){
        var  mutex_input_dblclick= 0;
        $(".icd-element-attribute").live("dblclick",function(){

            if(mutex_input_dblclick) return;
            else mutex_input_dblclick=1;
            /*
            clearTimeout(timer);
            */
            $(this).children().children("p").hide();
            $(this).children().children(".icd-element-input").show();
            $(this).children().children(".icd-element-input").children("input[type='text']").show();
            $(this).children(".btn-group").show();
        });

        $(".icd-element-attribute-input-submit").live("click",function(){
            var that =  $(this).parent().parent().children();

            var index_name = $(that).eq(0).children().children("input[type='text']");
            var name = $(index_name).val();
            if(name.replace( /^[" "|"　"]*/, "") === '') return;//去除所有均为空的情况

            var index_type = $(that).eq(1).children().children("input[type='text']");
            var type = $(index_type).val();
            if(type.replace( /^[" "|"　"]*/, "") === '') return;//去除所有均为空的情况

            var index_multi = $(that).eq(2).children().children("input[type='text']");
            var multi = $(index_multi).val();
            if(multi.replace( /^[" "|"　"]*/, "") === '') return;//去除所有均为空的情况

            $(index_name).parent().parent().children("p").text(name);
            $(index_type).parent().parent().children("p").text(type);
            $(index_multi).parent().parent().children("p").text(multi);
            $(this).parent().parent().parent().parent().children(".accordion-heading").children().children("p").text(name);

            $(this).parent().hide();

            $(index_name).hide();
            $(index_type).hide();
            $(index_multi).hide();

            $(index_name).parent().parent().children("p").show();
            $(index_type).parent().parent().children("p").show();
            $(index_multi).parent().parent().children("p").show();

            mutex_input_dblclick = 0;
        });

        $(".icd-element-attribute-input-cancel").live("click",function(){
            var that =  $(this).parent().parent().children();
            /*其实可以用是否为首次建立进行判断*/
            var index_name = $(that).eq(0).children().children("input[type='text']");
            var name = $(index_name).parent().parent().children("p").text();
            if(name.replace( /^[" "|"　"]*/, "") === '') return;//去除所有均为空的情况

            var index_type = $(that).eq(1).children().children("input[type='text']");
            var type = $(index_type).parent().parent().children("p").text();
            if(type.replace( /^[" "|"　"]*/, "") === '') return;//去除所有均为空的情况

            var index_multi = $(that).eq(2).children().children("input[type='text']");
            var multi = $(index_multi).parent().parent().children("p").text();
            if(multi.replace( /^[" "|"　"]*/, "") === '') return;//去除所有均为空的情况

            $(index_name).val(name);
            $(index_type).val(type);
            $(index_multi).val(multi);


            $(this).parent().hide();

            $(index_name).hide();
            $(index_type).hide();
            $(index_multi).hide();

            $(index_name).parent().parent().children("p").show();
            $(index_type).parent().parent().children("p").show();
            $(index_multi).parent().parent().children("p").show();

            mutex_input_dblclick = 0;
        });

        $(".icd-element-attribute-input-delete").live("click",function(){
            $(this).parent().parent().parent().parent().remove();
            mutex_input_dblclick = 0;
        });
    });
</script>